


class RegionModel{
  String countryName = "";
  String countryCode = "";
  String icon = "";
  String remark = "";

  static RegionModel fromJson(Map map){
    var model = RegionModel();
    model.countryName = map["countryName"] ?? "";
    model.countryCode = map["countryCode"] ?? "";
    model.icon = map["icon"];
    model.remark = map["remark"];
    return model;
  }

  static RegionModel fromCloudJson(Map map){
    var model = RegionModel();
    model.countryName = map["coutryName"] ?? "";
    model.countryCode = "+${map["coutryCode"] ?? ""}";
    model.icon = getFlagUrl(map["url"]);
    return model;
  }

  ///获取国旗的图片url
  static String getFlagUrl(String? flag) {
    String url = "";
    if (flag?.isNotEmpty == true) {
      url = "https://cloudpick.oss-cn-shanghai.aliyuncs.com/nationalflag/app/$flag.png";
    }
    return url;
  }
}